import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import "./assets/style/rest.css"
import './assets/style/common.css'
import {router} from "./router"
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { authModes } from './configs/conter'
import { createPinia } from 'pinia'

//设置白名单不登录的界面
    const pinia = createPinia()
    const app=createApp(App)
    app.directive('permissions',{
        mounted:(el:HTMLElement,binding:any)=>{
            const permissions=JSON.parse(localStorage.permissions)
            const {authvariable,authMode}=binding.value;
            const has=permissions.includes(authvariable)
            if(authMode===authModes.showOrNone){
                if(!has){
                    el.parentNode?.removeChild(el)
                }
            }else{
                if(!has){
                    el.setAttribute("disabled","true")
                    el.setAttribute("title","对不起没有权限")
                    el.classList.add("is-disabled")
                }
            }
            }
          
    })  
app.use(router).use(pinia).use(ElementPlus,{
    locale: zhCn,
}).mount('#app')
